package com.mz.mattress.client.service.impl;

import com.mz.mattress.api.common.Result;
import com.mz.mattress.api.entity.MemberCoupon;
import com.mz.mattress.api.util.IdUtil;
import com.mz.mattress.client.mapper.MemberCouponMapper;
import com.mz.mattress.client.service.CouponSendRecordService;
import com.mz.mattress.client.service.MemberCouponService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class MemberCouponServiceImpl implements MemberCouponService {

    @Autowired
    private MemberCouponMapper memberCouponMapper;

    @Autowired
    private CouponSendRecordService couponSendRecordService;

    @Override
    public Result<List<MemberCoupon>> list(Long memberId, String mobile, Integer money, Integer goodsId) {

        couponSendRecordService.loadByMobile(mobile);

        List<MemberCoupon> list = null;
        if (money == null) {
            list = memberCouponMapper.listAll(memberId);
        } else {
            list = memberCouponMapper.list(memberId, money, goodsId);
        }
        return Result.ok(list);

    }


    public static void main(String[] args) {

        String dd = IdUtil.uuid();

        System.out.println(dd.length());
        System.out.println(dd);
    }

}
